#pragma once
#include <graphics.h>
#include <vector>
#include <cstdlib>
#include <cmath>
#include "main.h"

extern int Color_Map[10];
extern void drawtile(int x, int y, int w, int h, int d, int color);

struct MEMORYBLOCK{
	int id;
	bool empty;
	void init(){
		id = -1;
		empty = true;
	}
};
struct MEMORY{
	struct MEMORYBLOCK memoryblock[MEMORY_MAX_NUM];
	int emptynum;
	void init(){
		emptynum = MEMORY_MAX_NUM;
		for(int i=0; i<MEMORY_MAX_NUM; i++)
			memoryblock[i].init();
	}
	int getoneblock(){
	//	if(status != BUF_FULL){
			for(int blocknum=0; blocknum<MEMORY_MAX_NUM; blocknum++){
				if(memoryblock[blocknum].empty == true){
					memoryblock[blocknum].empty = false;
					//emptynum--;
					/*if(emptynum == 0)
						status = BUF_FULL;
					else
						status = BUF_EXE;*/
					return blocknum;
				}
			}
		//}
		return -1;
	}
	void freeoneblock(int blocknum){
		memoryblock[blocknum].init();
		emptynum++;
		/*if(emptynum == MEMORY_MAX_NUM)
			status = BUF_EMPTY;
		else
			status = BUF_EXE;*/
	}
};
class MemoryRunning
{
public:
	MemoryRunning(void);
	~MemoryRunning(void);
	void init();
	void update();
	void drawonetile(int i, int j, int color, bool text, char name[FCB_NAME_LENGTH]);
	void show();
public:
	struct MEMORY m_Memory;
	int m_curblock;
private:
	int m_Hnum;
	int m_Width;
	int m_Height;
};

